using System;
using Microsoft.WindowsAzure.StorageClient;

namespace Azure.Domain.Models
{
    public static class Key
    {
        public static string Row(DateTime created)
        {
            return String.Format("{0:00000000000000000000}", DateTime.MaxValue.Ticks - created.Ticks);
        }

        public static string Partition(TableServiceEntity entity)
        {
            return entity.RowKey;
        }

        public static string Partition(DateTime date)
        {
            return String.Format(
                "{0:0000}{1:00}{2:00}",
                9999 - date.Year,
                99 - date.Month,
                99 - date.Day);
        }

        public static string Partition(int year, int month, int day)
        {
            return String.Format(
                "{0:0000}{1:00}{2:00}",
                9999 - year,
                99 - month,
                99 - day);
        }
    }
}